kopia lustrzana https://gitlab.com/jaywink/federation
A few code style cleanups in entities/test_base
rodzic
5eabc8faa1
commit
be329a5fe7
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -10,7 +9,7 @@ from federation.entities.base import (
|
||||||
from federation.tests.factories.entities import TaggedPostFactory, PostFactory
|
from federation.tests.factories.entities import TaggedPostFactory, PostFactory
|
||||||
|
|
||||||
|
|
||||||
class TestPostEntityTags(object):
|
class TestPostEntityTags():
|
||||||
def test_post_entity_returns_list_of_tags(self):
|
def test_post_entity_returns_list_of_tags(self):
|
||||||
post = TaggedPostFactory()
|
post = TaggedPostFactory()
|
||||||
assert post.tags == {"tagone", "tagtwo", "tagthree", "upper", "snakecase"}
|
assert post.tags == {"tagone", "tagtwo", "tagthree", "upper", "snakecase"}
|
||||||
|
@ -20,7 +19,7 @@ class TestPostEntityTags(object):
|
||||||
assert post.tags == set()
|
assert post.tags == set()
|
||||||
|
|
||||||
|
|
||||||
class TestBaseEntityCallsValidateMethods(object):
|
class TestBaseEntityCallsValidateMethods():
|
||||||
def test_entity_calls_attribute_validate_method(self):
|
def test_entity_calls_attribute_validate_method(self):
|
||||||
post = PostFactory()
|
post = PostFactory()
|
||||||
post.validate_location = Mock()
|
post.validate_location = Mock()
|
||||||
|
@ -50,21 +49,21 @@ class TestBaseEntityCallsValidateMethods(object):
|
||||||
post._validate_children()
|
post._validate_children()
|
||||||
|
|
||||||
|
|
||||||
class TestGUIDMixinValidate(object):
|
class TestGUIDMixinValidate():
|
||||||
def test_validate_guid_raises_on_low_length(self):
|
def test_validate_guid_raises_on_low_length(self):
|
||||||
guid = GUIDMixin(guid="x"*15)
|
guid = GUIDMixin(guid="x"*15)
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
guid.validate()
|
guid.validate()
|
||||||
|
|
||||||
|
|
||||||
class TestHandleMixinValidate(object):
|
class TestHandleMixinValidate():
|
||||||
def test_validate_handle_raises_on_invalid_format(self):
|
def test_validate_handle_raises_on_invalid_format(self):
|
||||||
handle = HandleMixin(handle="foobar")
|
handle = HandleMixin(handle="foobar")
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
handle.validate()
|
handle.validate()
|
||||||
|
|
||||||
|
|
||||||
class TestPublicMixinValidate(object):
|
class TestPublicMixinValidate():
|
||||||
def test_validate_public_raises_on_low_length(self):
|
def test_validate_public_raises_on_low_length(self):
|
||||||
public = PublicMixin(public="foobar")
|
public = PublicMixin(public="foobar")
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
|
@ -80,7 +79,7 @@ class TestSignedMixinValidate():
|
||||||
signed.validate()
|
signed.validate()
|
||||||
|
|
||||||
|
|
||||||
class TestEntityRequiredAttributes(object):
|
class TestEntityRequiredAttributes():
|
||||||
def test_entity_checks_for_required_attributes(self):
|
def test_entity_checks_for_required_attributes(self):
|
||||||
entity = BaseEntity()
|
entity = BaseEntity()
|
||||||
entity._required = ["foobar"]
|
entity._required = ["foobar"]
|
||||||
|
@ -96,7 +95,7 @@ class TestEntityRequiredAttributes(object):
|
||||||
entity.validate()
|
entity.validate()
|
||||||
|
|
||||||
|
|
||||||
class TestRelationshipEntity(object):
|
class TestRelationshipEntity():
|
||||||
def test_instance_creation(self):
|
def test_instance_creation(self):
|
||||||
entity = Relationship(handle="bob@example.com", target_handle="alice@example.com", relationship="following")
|
entity = Relationship(handle="bob@example.com", target_handle="alice@example.com", relationship="following")
|
||||||
assert entity
|
assert entity
|
||||||
|
@ -112,7 +111,7 @@ class TestRelationshipEntity(object):
|
||||||
entity.validate()
|
entity.validate()
|
||||||
|
|
||||||
|
|
||||||
class TestProfileEntity(object):
|
class TestProfileEntity():
|
||||||
def test_instance_creation(self):
|
def test_instance_creation(self):
|
||||||
entity = Profile(handle="bob@example.com", raw_content="foobar")
|
entity = Profile(handle="bob@example.com", raw_content="foobar")
|
||||||
assert entity
|
assert entity
|
||||||
|
@ -128,7 +127,7 @@ class TestProfileEntity(object):
|
||||||
entity.validate()
|
entity.validate()
|
||||||
|
|
||||||
|
|
||||||
class TestImageEntity(object):
|
class TestImageEntity():
|
||||||
def test_instance_creation(self):
|
def test_instance_creation(self):
|
||||||
entity = Image(
|
entity = Image(
|
||||||
guid="x"*16, handle="foo@example.com", public=False, remote_path="foobar", remote_name="barfoo"
|
guid="x"*16, handle="foo@example.com", public=False, remote_path="foobar", remote_name="barfoo"
|
||||||
|
@ -148,7 +147,7 @@ class TestImageEntity(object):
|
||||||
entity.validate()
|
entity.validate()
|
||||||
|
|
||||||
|
|
||||||
class TestRetractionEntity(object):
|
class TestRetractionEntity():
|
||||||
def test_instance_creation(self):
|
def test_instance_creation(self):
|
||||||
entity = Retraction(
|
entity = Retraction(
|
||||||
handle="foo@example.com", target_guid="x"*16, entity_type="Post"
|
handle="foo@example.com", target_guid="x"*16, entity_type="Post"
|
||||||
|
|
Ładowanie…
Reference in New Issue