本文整理汇总了Python中sunpy.database.tables.Tag类的典型用法代码示例。如果您正苦于以下问题:Python Tag类的具体用法?Python Tag怎么用?Python Tag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tag类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_remove_tag_undo_redo
def test_remove_tag_undo_redo(filled_database):
foo = Tag('foo')
foo.id = 1
fourth_entry = filled_database.get_entry_by_id(4)
assert foo in fourth_entry.tags
filled_database.remove_tag(fourth_entry, 'foo')
assert foo not in fourth_entry.tags
assert foo in filled_database.tags
filled_database.undo()
assert foo in fourth_entry.tags
assert foo in filled_database.tags
filled_database.redo()
assert foo not in fourth_entry.tags
assert foo in filled_database.tags
eighth_entry = filled_database.get_entry_by_id(8)
filled_database.remove_tag(eighth_entry, 'foo')
assert foo not in eighth_entry.tags
assert foo not in filled_database.tags
filled_database.undo()
assert foo not in fourth_entry.tags
assert foo in eighth_entry.tags
assert foo in filled_database.tags
filled_database.redo()
assert foo not in eighth_entry.tags
assert foo not in filled_database.tags
开发者ID:mirca,项目名称:sunpy,代码行数:25,代码来源:test_database.py
示例2: test_get_existing_tag
def test_get_existing_tag(database):
entry = DatabaseEntry()
database.tag(entry, 'tag')
database.add(entry)
expected_tag = Tag('tag')
expected_tag.id = 1
assert database.get_tag('tag') == expected_tag
开发者ID:mirca,项目名称:sunpy,代码行数:7,代码来源:test_database.py
示例3: test_getitem_exceeding_range
def test_getitem_exceeding_range(filled_database):
entries = filled_database[7:1000]
foo = Tag("foo")
foo.id = 1
bar = Tag("bar")
bar.id = 2
assert entries == [DatabaseEntry(id=8, tags=[foo]), DatabaseEntry(id=9), DatabaseEntry(id=10, tags=[bar])]
开发者ID:ericmjonas,项目名称:sunpy,代码行数:7,代码来源:test_database.py
示例4: test_getitem_negative_indices_slice
def test_getitem_negative_indices_slice(filled_database):
entries = filled_database[-2:-8:-2]
bar = Tag('bar')
bar.id = 2
assert entries == [
DatabaseEntry(id=9),
DatabaseEntry(id=7),
DatabaseEntry(id=5, tags=[bar])]
开发者ID:mirca,项目名称:sunpy,代码行数:8,代码来源:test_database.py
示例5: test_remove_many_entries
def test_remove_many_entries(filled_database):
bar = Tag("bar")
bar.id = 2
# required to check if `remove_many` adds any entries to undo-history
filled_database.clear_histories()
filled_database.remove_many(filled_database[:8])
assert len(filled_database) == 2
assert list(filled_database) == [DatabaseEntry(id=9), DatabaseEntry(id=10, tags=[bar])]
filled_database.undo()
assert len(filled_database) == 10
with pytest.raises(EmptyCommandStackError):
filled_database.undo()
开发者ID:ericmjonas,项目名称:sunpy,代码行数:12,代码来源:test_database.py
示例6: test_query
def test_query(filled_database):
foo = Tag('foo')
foo.id = 1
bar = Tag('bar')
bar.id = 2
entries = filled_database.query(
attrs.Tag('foo') | attrs.Tag('bar'), sortby='id')
assert len(entries) == 4
assert entries == [
DatabaseEntry(id=4, tags=[foo]),
DatabaseEntry(id=5, tags=[bar]),
DatabaseEntry(id=8, tags=[foo]),
DatabaseEntry(id=10, tags=[bar])]
开发者ID:mirca,项目名称:sunpy,代码行数:13,代码来源:test_database.py
示例7: test_query
def test_query(filled_database):
foo = Tag("foo")
foo.id = 1
bar = Tag("bar")
bar.id = 2
entries = filled_database.query(attrs.Tag("foo") | attrs.Tag("bar"), sortby="id")
assert len(entries) == 4
assert entries == [
DatabaseEntry(id=4, tags=[foo]),
DatabaseEntry(id=5, tags=[bar]),
DatabaseEntry(id=8, tags=[foo]),
DatabaseEntry(id=10, tags=[bar]),
]
开发者ID:ericmjonas,项目名称:sunpy,代码行数:13,代码来源:test_database.py
示例8: test_remove_tag
def test_remove_tag(filled_database):
foo = Tag("foo")
foo.id = 1
fourth_entry = filled_database.get_entry_by_id(4)
assert foo in fourth_entry.tags
eighth_entry = filled_database.get_entry_by_id(8)
assert foo in eighth_entry.tags
filled_database.remove_tag(fourth_entry, "foo")
assert foo not in fourth_entry.tags
assert foo in filled_database.tags
filled_database.remove_tag(eighth_entry, "foo")
assert foo not in eighth_entry.tags
assert foo not in filled_database.tags
开发者ID:ericmjonas,项目名称:sunpy,代码行数:13,代码来源:test_database.py
示例9: test_getitem_custom
def test_getitem_custom(filled_database):
entries = filled_database[1:5:2]
foo = Tag('foo')
foo.id = 1
assert entries == [
DatabaseEntry(id=2), DatabaseEntry(id=4, tags=[foo])]
开发者ID:mirca,项目名称:sunpy,代码行数:6,代码来源:test_database.py
注:本文中的sunpy.database.tables.Tag类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论