Skip to content

Commit

Permalink
Creating clusters and boards tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiola-m committed Oct 18, 2018
1 parent c375c2e commit f7fb0c7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/ej_boards/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ def test_create_board(self):
response = client.post('/profile/boards/add/', data=data)
self.assertRedirects(response, '/slug/', 302, 200)

def test_create_invalid_board(self):
client = self.logged_client
data = {'slug': 's', 'title': 'title', 'description': ''}
response = client.post('/profile/boards/add/', data=data)
self.assertTrue(response.status_code, 200)

def test_get_create_board(self):
client = self.logged_client
response = client.get('/profile/boards/add')
self.assertTrue(response.status_code, 200)

def test_create_board_anonymous_user(self):
client = Client()
response = client.get('/profile/boards/add/')
Expand Down
27 changes: 26 additions & 1 deletion src/ej_clusters/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest

from ej.testing import EjRecipes
from ej_conversations import mommy_recipes as conversations
from ej_conversations.models import Conversation
from ej_clusters.models import Cluster


@pytest.fixture
Expand All @@ -12,11 +15,33 @@ def conversation(db):
return conversation


class TestClusterization:
@pytest.fixture
def author(db):
return EjRecipes.author.make()


class TestClusterization():
def test_inject_clusters_related_manager_on_conversation(self, conversation):
assert hasattr(conversation.clusterization, 'clusters')
assert hasattr(conversation, 'clusters')

def test_clusterization_str_method(self, db, author):
conversation = Conversation.objects.create(author=author, title='title')
clusterization = conversation.clusterization
assert f'{conversation} (0 clusters)' == str(clusterization)

def test_clusterization_get_absolute_url(self, author, db):
conversation = Conversation.objects.create(author=author, title='title')
clusterization = conversation.clusterization
assert '/conversations/title/clusters/' == clusterization.get_absolute_url()


class TestCluster():
def test_cluster_str_method(self, db, author):
conversation = Conversation.objects.create(author=author, title='newtitle')
cluster = Cluster.objects.create(clusterization=conversation.clusterization, name='cluster')
assert str(cluster) == 'cluster ("newtitle" conversation)'


class TestStereotype:
def test_inject_stereotype_related_manager_on_conversation(self, conversation):
Expand Down

0 comments on commit f7fb0c7

Please sign in to comment.