예제 #1
0
    def test_get_source_from_user_and_url_existing_too_old(self):
        arbitrary_url = 'http://www.go.com/100'

        arbitrary_source = models.LocationSource.objects.create(
            name='Whatnot',
            user=self.user,
            type=self.source_type,
            data={
                'url': arbitrary_url,
                'known_points': {},
            },
        )
        arbitrary_source.created = datetime.datetime(1970, 1,
                                                     1).replace(tzinfo=utc)
        arbitrary_source.save()

        actual_source = RunmeterConsumer.get_source_from_user_and_url(
            self.user,
            arbitrary_url,
        )

        self.assertNotEqual(
            arbitrary_source.pk,
            actual_source.pk,
        )
    def test_get_source_from_user_and_url_new(self):
        arbitrary_url = "http://www.go.com/100"

        actual_source = RunmeterConsumer.get_source_from_user_and_url(self.user, arbitrary_url)

        assertions = {"type": self.source_type, "data": {"url": arbitrary_url, "known_points": {}}, "active": True}

        for k, v in assertions.items():
            self.assertEqual(getattr(actual_source, k), v)
    def test_get_source_from_user_and_url_existing(self):
        arbitrary_url = "http://www.go.com/100"

        arbitrary_source = models.LocationSource.objects.create(
            name="Whatnot", user=self.user, type=self.source_type, data={"url": arbitrary_url, "known_points": {}}
        )

        actual_source = RunmeterConsumer.get_source_from_user_and_url(self.user, arbitrary_url)

        self.assertEqual(arbitrary_source.pk, actual_source.pk)
    def test_get_source_from_user_and_url_existing_too_old(self):
        arbitrary_url = "http://www.go.com/100"

        arbitrary_source = models.LocationSource.objects.create(
            name="Whatnot", user=self.user, type=self.source_type, data={"url": arbitrary_url, "known_points": {}}
        )
        arbitrary_source.created = datetime.datetime(1970, 1, 1).replace(tzinfo=utc)
        arbitrary_source.save()

        actual_source = RunmeterConsumer.get_source_from_user_and_url(self.user, arbitrary_url)

        self.assertNotEqual(arbitrary_source.pk, actual_source.pk)
예제 #5
0
    def test_get_source_from_user_and_url_new(self):
        arbitrary_url = 'http://www.go.com/100'

        actual_source = RunmeterConsumer.get_source_from_user_and_url(
            self.user,
            arbitrary_url,
        )

        assertions = {
            'type': self.source_type,
            'data': {
                'url': arbitrary_url,
                'known_points': {},
            },
            'active': True
        }

        for k, v in assertions.items():
            self.assertEqual(getattr(actual_source, k), v)
예제 #6
0
    def test_get_source_from_user_and_url_existing(self):
        arbitrary_url = 'http://www.go.com/100'

        arbitrary_source = models.LocationSource.objects.create(
            name='Whatnot',
            user=self.user,
            type=self.source_type,
            data={
                'url': arbitrary_url,
                'known_points': {},
            })

        actual_source = RunmeterConsumer.get_source_from_user_and_url(
            self.user,
            arbitrary_url,
        )

        self.assertEqual(
            arbitrary_source.pk,
            actual_source.pk,
        )