from nose.tools import eq_
from tornado.httpclient import HTTPRequest
import uuid

from astral.api.tests import BaseTest
from astral.models.node import Node

class NodeHandlerTest(BaseTest):
    def test_delete_node(self):
        node = Node(uuid=uuid.getnode())
        self.http_client.fetch(HTTPRequest(
            self.get_url(node.absolute_url()), 'DELETE'), self.stop)
        response = self.wait()
        eq_(response.code, 200)
        eq_(Node.get_by(uuid=node.uuid), None)

from nose.tools import eq_
from tornado.httpclient import HTTPRequest

from astral.api.tests import BaseTest
from astral.models import Node
from astral.models.tests.factories import NodeFactory

class NodeHandlerTest(BaseTest):
    def test_delete_node(self):
        node = NodeFactory()
        self.http_client.fetch(HTTPRequest(
            self.get_url(node.absolute_url()), 'DELETE'), self.stop)
        response = self.wait()
        eq_(response.code, 200)
        eq_(Node.get_by(uuid=node.uuid), None)

Build proper Node in tests after refactoring constructor.
Build proper Node in tests after refactoring constructor.

  from nose.tools import eq_
  from tornado.httpclient import HTTPRequest
- import uuid
  
  from astral.api.tests import BaseTest
- from astral.models.node import Node
+ from astral.models import Node
+ from astral.models.tests.factories import NodeFactory
  
  class NodeHandlerTest(BaseTest):
      def test_delete_node(self):
-         node = Node(uuid=uuid.getnode())
+         node = NodeFactory()
          self.http_client.fetch(HTTPRequest(
              self.get_url(node.absolute_url()), 'DELETE'), self.stop)
          response = self.wait()
          eq_(response.code, 200)
          eq_(Node.get_by(uuid=node.uuid), None)
  
Build proper Node in tests after refactoring constructor.
## Code Before:
from nose.tools import eq_
from tornado.httpclient import HTTPRequest
import uuid

from astral.api.tests import BaseTest
from astral.models.node import Node

class NodeHandlerTest(BaseTest):
    def test_delete_node(self):
        node = Node(uuid=uuid.getnode())
        self.http_client.fetch(HTTPRequest(
            self.get_url(node.absolute_url()), 'DELETE'), self.stop)
        response = self.wait()
        eq_(response.code, 200)
        eq_(Node.get_by(uuid=node.uuid), None)

## Instruction:
Build proper Node in tests after refactoring constructor.
## Code After:
from nose.tools import eq_
from tornado.httpclient import HTTPRequest

from astral.api.tests import BaseTest
from astral.models import Node
from astral.models.tests.factories import NodeFactory

class NodeHandlerTest(BaseTest):
    def test_delete_node(self):
        node = NodeFactory()
        self.http_client.fetch(HTTPRequest(
            self.get_url(node.absolute_url()), 'DELETE'), self.stop)
        response = self.wait()
        eq_(response.code, 200)
        eq_(Node.get_by(uuid=node.uuid), None)
