
import unittest
from phoxpy import client
from phoxpy.tests.lisserver import MockHttpSession

class SessionTestCase(unittest.TestCase):

    def test_login(self):
        session = client.Session(login='John', password='Doe',
                                 client_id='foo-bar-baz')
        self.assertFalse(session.is_active())
        session.open('localhost', http_session=MockHttpSession())
        self.assertTrue(session.is_active())

    def test_logout(self):
        session = client.Session(login='John', password='Doe',
                                 client_id='foo-bar-baz')
        self.assertFalse(session.is_active())
        session.open('localhost', http_session=MockHttpSession())
        self.assertTrue(session.is_active())
        session.close()
        self.assertFalse(session.is_active())


if __name__ == '__main__':
    unittest.main()


import unittest
from phoxpy import client
from phoxpy.server import MockHttpSession, SimpleLISServer


class SessionTestCase(unittest.TestCase):

    def setUp(self):
        self.server = SimpleLISServer('4.2', '31415')
        self.server.ext_auth.add_license('foo-bar-baz')
        self.server.ext_auth.add_user('John', 'Doe')

    def test_login(self):
        session = client.Session(login='John', password='Doe',
                                 client_id='foo-bar-baz')
        self.assertFalse(session.is_active())
        session.open('localhost', http_session=MockHttpSession(self.server))
        self.assertTrue(session.is_active())

    def test_logout(self):
        session = client.Session(login='John', password='Doe',
                                 client_id='foo-bar-baz')
        self.assertFalse(session.is_active())
        session.open('localhost', http_session=MockHttpSession(self.server))
        self.assertTrue(session.is_active())
        session.close()
        self.assertFalse(session.is_active())


if __name__ == '__main__':
    unittest.main()

Update tests for new environment.
Update tests for new environment.

  
  import unittest
  from phoxpy import client
- from phoxpy.tests.lisserver import MockHttpSession
+ from phoxpy.server import MockHttpSession, SimpleLISServer
+ 
  
  class SessionTestCase(unittest.TestCase):
+ 
+     def setUp(self):
+         self.server = SimpleLISServer('4.2', '31415')
+         self.server.ext_auth.add_license('foo-bar-baz')
+         self.server.ext_auth.add_user('John', 'Doe')
  
      def test_login(self):
          session = client.Session(login='John', password='Doe',
                                   client_id='foo-bar-baz')
          self.assertFalse(session.is_active())
-         session.open('localhost', http_session=MockHttpSession())
+         session.open('localhost', http_session=MockHttpSession(self.server))
          self.assertTrue(session.is_active())
  
      def test_logout(self):
          session = client.Session(login='John', password='Doe',
                                   client_id='foo-bar-baz')
          self.assertFalse(session.is_active())
-         session.open('localhost', http_session=MockHttpSession())
+         session.open('localhost', http_session=MockHttpSession(self.server))
          self.assertTrue(session.is_active())
          session.close()
          self.assertFalse(session.is_active())
  
  
  if __name__ == '__main__':
      unittest.main()
  
Update tests for new environment.
## Code Before:

import unittest
from phoxpy import client
from phoxpy.tests.lisserver import MockHttpSession

class SessionTestCase(unittest.TestCase):

    def test_login(self):
        session = client.Session(login='John', password='Doe',
                                 client_id='foo-bar-baz')
        self.assertFalse(session.is_active())
        session.open('localhost', http_session=MockHttpSession())
        self.assertTrue(session.is_active())

    def test_logout(self):
        session = client.Session(login='John', password='Doe',
                                 client_id='foo-bar-baz')
        self.assertFalse(session.is_active())
        session.open('localhost', http_session=MockHttpSession())
        self.assertTrue(session.is_active())
        session.close()
        self.assertFalse(session.is_active())


if __name__ == '__main__':
    unittest.main()

## Instruction:
Update tests for new environment.
## Code After:

import unittest
from phoxpy import client
from phoxpy.server import MockHttpSession, SimpleLISServer


class SessionTestCase(unittest.TestCase):

    def setUp(self):
        self.server = SimpleLISServer('4.2', '31415')
        self.server.ext_auth.add_license('foo-bar-baz')
        self.server.ext_auth.add_user('John', 'Doe')

    def test_login(self):
        session = client.Session(login='John', password='Doe',
                                 client_id='foo-bar-baz')
        self.assertFalse(session.is_active())
        session.open('localhost', http_session=MockHttpSession(self.server))
        self.assertTrue(session.is_active())

    def test_logout(self):
        session = client.Session(login='John', password='Doe',
                                 client_id='foo-bar-baz')
        self.assertFalse(session.is_active())
        session.open('localhost', http_session=MockHttpSession(self.server))
        self.assertTrue(session.is_active())
        session.close()
        self.assertFalse(session.is_active())


if __name__ == '__main__':
    unittest.main()
