from flask import url_for

class TestBreakTheOrder:
    """
    Breaking the order
    """
    def test_order_is_not_not_found(self, testapp):
        """
        There actually is an order... Amazing. 
        I know, right?
        """
        # !!! URL needs the / at the end.
        res = testapp.get('/orders/')
        assert res.status_code != 404

    def test_order_is_accessible(self, testapp):
        """
        Breaching the order?! Success!
        """
        # testapp made available from the tests module
        res = testapp.get('/orders/')
        assert res.status_code == 200

    def test_order_has_list_of_not_beer(self, testapp):
        """
        Range of beer is NOT available!
        Do I look like Robin?
        """
        res = testapp.get('/orders/orders')
        # i have discovered that "string" in res is case sensitive
        # in general to know more see:
        # http://webtest.readthedocs.io/en/latest/api.html#webtest-response-testresponse
        assert "List of NOT beer" in res

    def test_browse_list_returns_empty_list(self, order, testapp):
        res = testapp.get('/orders/ordersList')
        assert "data" in res

from flask import url_for


class TestBreakTheOrder:
    """
    Breaking the order
    """

    def test_order_gives_401_without_login(self, testapp):
        """
        There actually is an order... Amazing.
        I know, right?
        """
        # !!! URL needs the / at the end.
        res = testapp.get('/orders/', expect_errors=True)
        print(res)
        print(res.status_code)
        assert res.status_code == 401

    def test_order_has_list_of_not_beer(self, testapp):
        """
        Range of beer is NOT available!
        Do I look like Robin?
        """
        res = testapp.get('/orders/orders')
        # i have discovered that "string" in res is case sensitive
        # in general to know more see:
        # http://webtest.readthedocs.io/en/latest/api.html#webtest-response-testresponse
        assert "List of NOT beer" in res

    def test_browse_list_returns_empty_list(self, order, testapp):
        res = testapp.get('/orders/ordersList')
        assert "data" in res

Update test order to check for 401.
Update test order to check for 401.

  from flask import url_for
+ 
  
  class TestBreakTheOrder:
      """
      Breaking the order
      """
+ 
-     def test_order_is_not_not_found(self, testapp):
+     def test_order_gives_401_without_login(self, testapp):
          """
-         There actually is an order... Amazing. 
+         There actually is an order... Amazing.
          I know, right?
          """
          # !!! URL needs the / at the end.
-         res = testapp.get('/orders/')
+         res = testapp.get('/orders/', expect_errors=True)
+         print(res)
+         print(res.status_code)
-         assert res.status_code != 404
+         assert res.status_code == 401
- 
-     def test_order_is_accessible(self, testapp):
-         """
-         Breaching the order?! Success!
-         """
-         # testapp made available from the tests module
-         res = testapp.get('/orders/')
-         assert res.status_code == 200
  
      def test_order_has_list_of_not_beer(self, testapp):
          """
          Range of beer is NOT available!
          Do I look like Robin?
          """
          res = testapp.get('/orders/orders')
          # i have discovered that "string" in res is case sensitive
          # in general to know more see:
          # http://webtest.readthedocs.io/en/latest/api.html#webtest-response-testresponse
          assert "List of NOT beer" in res
  
      def test_browse_list_returns_empty_list(self, order, testapp):
          res = testapp.get('/orders/ordersList')
          assert "data" in res
  
Update test order to check for 401.
## Code Before:
from flask import url_for

class TestBreakTheOrder:
    """
    Breaking the order
    """
    def test_order_is_not_not_found(self, testapp):
        """
        There actually is an order... Amazing. 
        I know, right?
        """
        # !!! URL needs the / at the end.
        res = testapp.get('/orders/')
        assert res.status_code != 404

    def test_order_is_accessible(self, testapp):
        """
        Breaching the order?! Success!
        """
        # testapp made available from the tests module
        res = testapp.get('/orders/')
        assert res.status_code == 200

    def test_order_has_list_of_not_beer(self, testapp):
        """
        Range of beer is NOT available!
        Do I look like Robin?
        """
        res = testapp.get('/orders/orders')
        # i have discovered that "string" in res is case sensitive
        # in general to know more see:
        # http://webtest.readthedocs.io/en/latest/api.html#webtest-response-testresponse
        assert "List of NOT beer" in res

    def test_browse_list_returns_empty_list(self, order, testapp):
        res = testapp.get('/orders/ordersList')
        assert "data" in res

## Instruction:
Update test order to check for 401.
## Code After:
from flask import url_for


class TestBreakTheOrder:
    """
    Breaking the order
    """

    def test_order_gives_401_without_login(self, testapp):
        """
        There actually is an order... Amazing.
        I know, right?
        """
        # !!! URL needs the / at the end.
        res = testapp.get('/orders/', expect_errors=True)
        print(res)
        print(res.status_code)
        assert res.status_code == 401

    def test_order_has_list_of_not_beer(self, testapp):
        """
        Range of beer is NOT available!
        Do I look like Robin?
        """
        res = testapp.get('/orders/orders')
        # i have discovered that "string" in res is case sensitive
        # in general to know more see:
        # http://webtest.readthedocs.io/en/latest/api.html#webtest-response-testresponse
        assert "List of NOT beer" in res

    def test_browse_list_returns_empty_list(self, order, testapp):
        res = testapp.get('/orders/ordersList')
        assert "data" in res
