Beispiel #1
0
    def test_basic_correlation(self):
        group = GroupFactory(started=datetime.date(2013, 1, 1))
        assert Correlation.objects.count() == 1

        correlation = Correlation.objects.all()[0]
        assert correlation.timestamp == group.started
        assert correlation.identifier == 'group'
        assert correlation.date_field == 'started'
        assert correlation.julian == 1
        assert correlation.year == 2013
        assert correlation.month == 1
        assert correlation.day == 1

        # Take the same group and change the started date, this should update
        # the correlation, rather than create a new one.
        group.started = datetime.date(2013, 1, 2)
        group.save()
        assert Correlation.objects.count() == 1

        correlation = Correlation.objects.all()[0]
        assert correlation.timestamp == group.started
        assert correlation.julian == 2
        assert correlation.year == 2013
        assert correlation.month == 1
        assert correlation.day == 2
Beispiel #2
0
    def test_generations(self):
        group = GroupFactory()
        idols = [IdolFactory() for i in xrange(3)]
        [
            MembershipFactory(
                group=group, idol=idols[i], generation=i + 1
            ) for i in xrange(3)
        ]

        generations = group.generations()
        assert len(generations) == 3
        for k, v in generations.iteritems():
            assert isinstance(k, int)
            assert len(v) == 1
Beispiel #3
0
    def test_targeted_is_active(self):
        targeted_active = GroupFactory()
        assert targeted_active.is_active(target=today)

        targeted_inactive = GroupFactory(ended=today - delta)
        assert not targeted_inactive.is_active(target=today)

        targeted_upcoming = GroupFactory(started=today + delta)
        assert not targeted_upcoming.is_active(target=today)
Beispiel #4
0
 def test_generations_failure(self):
     group = GroupFactory()
     idols = [IdolFactory() for i in xrange(3)]
     [MembershipFactory(group=group, idol=idols[i]) for i in xrange(3)]
     assert not group.generations()
Beispiel #5
0
 def test_get_absolute_url(self, client):
     factory = GroupFactory()
     response = client.get(factory.get_absolute_url())
     assert response.status_code == 200