Ejemplo n.º 1
0
    def test_old_version(self):
        ver = Version.objects.get(pk=1)
        data = {}
        data["version"] = '0.0.0'
        data["os.name"] = platform.system()
        data["os.arch"] = platform.machine()
        data["os.version"] = getOSVersion()
        data["python.version"] = platform.python_version()
        data["python.compiler"] = platform.python_compiler()
        data["python.build"] = platform.python_build()

        hit_url = reverse('registry_hit')

        request = self.factory.get(hit_url, data,
                                   HTTP_USER_AGENT='OMERO.test')

        response = views_hit(request)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(
            response.content,
            ('Please upgrade to %s. See '
             'http://downloads.openmicroscopy.org/latest-stable/omero'
             ' for the latest version.') % ver.version)

        hit = Hit.objects.get(agent_version=data["version"])
        self.assertEqual(hit.agent.agent_name, 'OMERO.test')
        self.assertEqual(hit.os_name, data["os.name"])
        self.assertEqual(hit.os_arch, data["os.arch"])
        self.assertEqual(hit.os_version, data["os.version"])
        self.assertEqual(hit.python_version, data["python.version"])
        self.assertEqual(hit.python_compiler, data["python.compiler"][:50])
        self.assertEqual(hit.python_build, data["python.build"][1])
Ejemplo n.º 2
0
    def test_current_version(self):
        ver = Version.objects.get(pk=1)
        data = {}
        data["version"] = ver.version
        data["os.name"] = platform.system()
        data["os.arch"] = platform.machine()
        data["os.version"] = getOSVersion()
        data["python.version"] = platform.python_version()
        data["python.compiler"] = platform.python_compiler()
        data["python.build"] = platform.python_build()
    
        hit_url = reverse('registry_hit')

        request = self.factory.get(hit_url, data,
                                   HTTP_USER_AGENT='OMERO.test')

        response = views_hit(request)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, '')

        hit = Hit.objects.get(agent_version=data["version"])
        self.assertEqual(hit.agent.agent_name, 'OMERO.test')
        self.assertEqual(hit.os_name, data["os.name"])
        self.assertEqual(hit.os_arch, data["os.arch"])
        self.assertEqual(hit.os_version, data["os.version"])
        self.assertEqual(hit.python_version, data["python.version"])
        self.assertEqual(hit.python_compiler, data["python.compiler"][:50])
        self.assertEqual(hit.python_build, data["python.build"][1])
Ejemplo n.º 3
0
    def test_bad_agent(self):
        hit_url = reverse('registry_hit')

        request = self.factory.get(hit_url, HTTP_USER_AGENT='foo')
        response = views_hit(request)
        self.assertEqual(response.status_code,302)

        # check if nothing was created
        self.assertEqual(Hit.objects.all().count(), 0)